﻿<!DOCTYPE html>
<!--承包商违章台账列表-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <link href="/static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="/static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .el-dialog__body {
            height: 100% !important;
        }
    </style>
</head>

<body>
    
<div id="app" v-cloak>   
        <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
            style="margin-bottom: 15px;">

            <el-row>
                <el-col class="head-tool">
                    
<div class="new_title fl"><strong><img src="/static/images/icon1.png" />承包商违章台账列表</strong></div>
                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>
                        <!--<btn-uploadfile-list url="xxxx" linetype="3"></btn-uploadfile-list>-->
                        <btn-export-list url="/api/CBS_BreakRules/Export" :forminline="this.formInline" linetype="3">
                        </btn-export-list>
                        <!--<btn :text="col.btnExamine" imgsrc="/static/images/general.png" linetype="3" @click="Examine">
                        </btn>-->
                        <btn :text="col.btnContractorQZ" imgsrc="/static/images/general.png" linetype="3"
                            @click="btnContractorQZ"></btn>
                        <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row>
                <!--工厂组件-->
                <list-factorys v-model="formInline.model.CreateFactory" @change="factoryChange"></list-factorys>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{ContractorPersonnelDirectory.ContractorName+mark.m}}
                                </template>
                                <el-select @visible-change="visibleChange" v-model="formInline.model.CBSListId" slot="suffix"
                                           :placeholder="ContractorPersonnelDirectory.ContractorName">
                                    <el-option label="请选择" value=""></el-option>
                                    <el-option v-for="item in CBS_Lists" :label="item.contractorName"
                                               :value="item.id"></el-option>
                                </el-select>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="8" :sm="8" :md="8" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item  prop="areaID">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{ContractorViolationAccount.FoundArea+mark.m}}
                                </template>
                                <treeselect v-model="formInline.model.areaID" :options="AreaList" :flat="true" slot="suffix"
                                            style="line-height: 28px;width:70%;" :disable-branch-nodes="true"
                                            placeholder="请选择区域" />
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>

            </el-row>
        </el-form>

        <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
            @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%">
            <el-table-column type="selection" align="center" width="55">
            </el-table-column>
            <el-table-column type="index" :label="ContractorDirectory.SerialNumber" :index="indexMethod" width="50"
                show-overflow-tooltip="true"></el-table-column>

            <el-table-column prop="cbS_List.contractorName" :label="ContractorViolationAccount.ContractorName" width="180">
            </el-table-column>

            <el-table-column prop="violationDate" :label="ContractorViolationAccount.ViolationDate":formatter="myformatDate" min-width="100"
                show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="violationInstructions" :label="ContractorViolationAccount.ViolationInstructions"
                show-overflow-tooltip="true" min-width="260">
            </el-table-column>

            <el-table-column prop="cbS_User.personnelName" :label="ContractorViolationAccount.Violators" min-width="80"
                show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="violationClause" :label="ContractorViolationAccount.ViolationClause"
                show-overflow-tooltip="true" min-width="260">
            </el-table-column>
            <el-table-column prop="sysArea.name" :label="ContractorViolationAccount.FoundArea" min-width="80"
                show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="discoveringPeople" :label="ContractorViolationAccount.DiscoveringPeople"
                min-width="80" show-overflow-tooltip="true">
            </el-table-column>
            <!--<el-table-column prop="editor" :label="ContractorViolationAccount.editor"
                show-overflow-tooltip="true" min-width="100">
            </el-table-column>
            <el-table-column prop="editorTime" :label="ContractorViolationAccount.editorTime"
                show-overflow-tooltip="true" min-width="120">
            </el-table-column>-->
            <!-- <el-table-column prop="ExamineState" :label="ContractorViolationAccount.ExamineState">
            </el-table-column> -->
            <!--<el-table-column prop="remarks"
                             :label="ContractorViolationAccount.Remarks" show-overflow-tooltip="true" min-width="120">
            </el-table-column>-->
            <el-table-column prop="stateText" label="状态" min-width="140"  show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                <template slot-scope="scope" v-if="scope.row.state=='1'">
                        <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                            <i class="el-icon-edit"></i>
                        </button>
                </template>
            </el-table-column>
        </el-table>
        <el-row type="flex" justify="end">
            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>
        </el-row>
        <el-dialog title="承包商违章台账管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%"
            height="80%" top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    CBS_Lists: [],
                    FoundArea: [],
                    AreaList:[],
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            AreaID:'',
                            ContractorName: '',
                            ViolationDate: '',
                            ViolationInstructions: '',
                            Violators: '',
                            ViolationClause: '',
                            DiscoveringPeople: '',
                            ProcessingOpinion: '',
                            FoundArea: '',
                            Remarks: '',
                            ExamineState: '',
                            CBSListId: ''
                        },
                        offset: 0,
                        limit: 10
                    }
                }
            }, created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                //获取下拉菜单内容
                //this.FoundArea = getDicData('n69');
                //this.GetAreaList();//初始化区域
                //初始化数据
                //this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                indexMethod: function (index) {
                    return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1;
                },
                handleNodeClick: function (data) {
                    console.log(data);
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/CBS_BreakRules/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "ContractorViolationAccountInput.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/CBS_BreakRules/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },

                Examine: function () {

                    if (this.ListItem.tableMultipleSelection.length != 1) {

                        showMessage(msg.OnlyOne, 'error')
                        return;
                    }
                    DialogShow(this, "xg", "ContractorViolationAccountApprovalInput.html", this.ListItem.tableMultipleSelection[0].id);
                },
                btnContractorQZ: function () {
                    if (this.ListItem.tableMultipleSelection.length == 0) {

                        showMessage(msg.OnlyOne, 'error')
                        return;
                    }
                    if (this.ListItem.tableMultipleSelection.length > 1) {

                        showMessage(msg.OnlyOne, 'error')
                        return;
                    }
                    DialogShow(this, "xg", "ContractorViolationSignatureInput.html", this.ListItem.tableMultipleSelection[0].id);
                },
                GetAreaList: function (type) {
                    var mythis = this;
                    myAjax("post", this, '/api/SysArea/GetList', { model: { Name: '', Code: '', SubFactory: this.formInline.model.CreateFactory }, offset: 0, limit: 999 }
                        , function (response) {
                            mythis.AreaList = menuHelper(response.data.pageData, guidEmpty);
                            console.log('oooooo', mythis.AreaList);
                        },
                        false);
                },
                //初始化承包商下拉框
                getCBS_List: function () {
                    var mythis = this;
                    myAjax("post", this, '/api/CBS_List/GetList', { model: { status: '', CreateFactory: this.formInline.model.CreateFactory }, offset: 0, limit: 100 }, function (response) {
                        mythis.CBS_Lists = response.data.pageData;
                    }, false);
                },
                factoryChange: function () {
                    this.getCBS_List();
                    this.GetAreaList();//初始化区域
                    this.GetPageData(1);
                },
            }
        });
        //数据序列化(tabletree)
        function menuHelper(list, pid) {
            var result = [];
            if (list.length <= 0)
                return list;
            list.forEach(function (v, i) {
                var temp = {};
                for (var key in v) {
                    temp[key] = v[key];
                }
                temp.label = v.name;
                temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                var obj;
                if (temp.parentId == pid) {
                    obj = temp;
                    var nextObj = menuHelper(list, temp.id);
                    if (nextObj.length > 0) {
                        obj.children = nextObj;
                    }
                }
                if (obj)
                    result.push(obj)
            })
            return result;
        }
    </script>
</body>

</html>